﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using CarLoanSystem.Entity;

namespace CarLoanSystem
{
    public partial class frmAddInterrest : Form
    {
        private static InterrestInfoItem interrestItem;
        public frmAddInterrest()
        {
            InitializeComponent();
            cbbDownRate.DataSource = DAL.DownPaymentInfoDAL.LoadAllDownPayment();
            cbbDownRate.ValueMember = "DOWN_PAYMENT_ID";
            cbbDownRate.DisplayMember = "DOWN_PAYMENT_RATE";
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnSave_Click(object sender, EventArgs e)
        {
            interrestItem = new InterrestInfoItem();
            interrestItem.DEBT_MONTH = Convert.ToInt32(this.txtMonth.Text);
            interrestItem.INTERREST_RATE = Convert.ToDecimal(this.txtInterestRate.Text);
            interrestItem.DOWN_PAYMENT_ID = Convert.ToInt32(this.cbbDownRate.SelectedValue);
            DAL.InterrestInfoDAL.Insert(interrestItem);
            MessageBox.Show("บันทึกข้อมูลเรียบร้อย","ข้อมูลอัตราเงินดาวน์");
            this.Close();
        }
    }
}
